package com.uatair.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.uatair.system.service.ITpSortieTaskService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uatair.common.annotation.Log;
import com.uatair.common.core.controller.BaseController;
import com.uatair.common.core.domain.AjaxResult;
import com.uatair.common.enums.BusinessType;
import com.uatair.system.domain.TpSortieTask;
import com.uatair.common.utils.poi.ExcelUtil;
import com.uatair.common.core.page.TableDataInfo;

/**
 * 飞行架次Controller
 * 
 * @author uatair
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/system/sortie")
public class TpSortieController extends BaseController
{
    @Autowired
    private ITpSortieTaskService tpSortieTaskService;

    /**
     * 查询飞行架次列表
     */
    @PreAuthorize("@ss.hasPermi('system:uav:list')")
    @GetMapping("/list")
    public TableDataInfo list(TpSortieTask tpSortieTask)
    {
        startPage();
        List<TpSortieTask> list = tpSortieTaskService.selectTpSortieTaskList(tpSortieTask);
        return getDataTable(list);
    }

    /**
     * 导出飞行架次列表
     */
    @PreAuthorize("@ss.hasPermi('system:sortie:export')")
    @Log(title = "飞行架次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TpSortieTask tpSortieTask)
    {
        List<TpSortieTask> list = tpSortieTaskService.selectTpSortieTaskList(tpSortieTask);
        ExcelUtil<TpSortieTask> util = new ExcelUtil<TpSortieTask>(TpSortieTask.class);
        util.exportExcel(response, list, "飞行架次数据");
    }

    /**
     * 获取飞行架次详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sortie:query')")
    @GetMapping(value = "/{sortieNo}")
    public AjaxResult getInfo(@PathVariable("sortieNo") String sortieNo)
    {
//        tpSortieTaskService.selectTpSortieBySortieNo(sortieNo)
        return success();
    }

    /**
     * 新增飞行架次
     */
    @PreAuthorize("@ss.hasPermi('system:sortie:add')")
    @Log(title = "飞行架次", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TpSortieTask tpSortieTask)
    {
        return toAjax(tpSortieTaskService.insertTpSortieTask(tpSortieTask));
    }

    /**
     * 修改飞行架次
     */
    @PreAuthorize("@ss.hasPermi('system:sortie:edit')")
    @Log(title = "飞行架次", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TpSortieTask tpSortieTask)
    {
        return toAjax(tpSortieTaskService.updateTpSortieTask(tpSortieTask));
    }

    /**
     * 删除飞行架次
     */
    @PreAuthorize("@ss.hasPermi('system:sortie:remove')")
    @Log(title = "飞行架次", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sortieNos}")
    public AjaxResult remove(@PathVariable String[] sortieNos)
    {
//        tpSortieTaskService.deleteTpSortieBySortieNos(sortieNos)
        return toAjax(true);
    }
}
